package cn.jy.careuplusdoctor.widgets;

import cn.jy.careuplusdoctor.R;
import cn.jy.careuplusdoctor.injector.IdInject;
import cn.jy.careuplusdoctor.injector.InjectorUitls;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 标题栏
 * @author lxy
 * @date 2015-07-10
 * @version V1.0
 *
 */
public class CareuTitleBar {
	
	@IdInject(id = R.id.title_bar_ll_left)
	private View mLeftView;
	@IdInject(id = R.id.title_bar_ll_right)
	private View mRightView;
	@IdInject(id = R.id.title_bar_img_left)
	private ImageView mLeftImageView;
	@IdInject(id = R.id.title_bar_img_right)
	private ImageView mRightImageView;
	@IdInject(id = R.id.title_bar_tv_title)
	private TextView mTitleTextView;
	@IdInject(id = R.id.title_bar_tv_left)
	private TextView mLeftTextView;
	@IdInject(id = R.id.title_bar_tv_right)
	private TextView mRightTextView;
	
	private TitleBarLeftAction leftAction;
	private TitleBarRightAction rightAction;
	
	
	public CareuTitleBar(Activity activity) {
		init(activity);
	}
	
	private void init(Activity activity)
	{
		InjectorUitls.getInstance().injectFromView(CareuTitleBar.this,activity.findViewById(R.id.fl_title_bar));
		OnClickListener listener = new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if (v.getId() == R.id.title_bar_ll_left && leftAction !=null) {
					leftAction.onLeftPress(v);
				}
				else if (v.getId() == R.id.title_bar_ll_right && rightAction !=null) {
					rightAction.onRightPress(v);
				}
			}
		};
		mLeftView.setOnClickListener(listener);
		mRightView.setOnClickListener(listener);
	}

	public void setLeftAction(TitleBarLeftAction leftAction) {
		this.leftAction = leftAction;
	}

	public void setRightAction(TitleBarRightAction rightAction) {
		this.rightAction = rightAction;
	}

	public void setTitle(String title)
	{
		mTitleTextView.setText(title);
	}
	
	public void setTitle(int resStr)
	{
		mTitleTextView.setText(resStr);
	}
	
	
	public void setLeftText(String title)
	{
		mLeftTextView.setText(title);
	}
	
	public void setLeftText(int resStr)
	{
		mLeftTextView.setText(resStr);
	}
	
	public void setRightText(String title)
	{
		mRightTextView.setText(title);
	}
	
	public void setRightText(int resStr)
	{
		mRightTextView.setText(resStr);
	}

	public ImageView getLeftImageView() {
		return mLeftImageView;
	}

	public void setLeftImageView(ImageView mLeftImageView) {
		this.mLeftImageView = mLeftImageView;
	}

	public ImageView getRightImageView() {
		return mRightImageView;
	}

	public void setRightImageView(ImageView mRighImageView) {
		this.mRightImageView = mRighImageView;
	}

	public TextView getTitleTextView() {
		return mTitleTextView;
	}

	public void setTitleTextView(TextView mTitle) {
		this.mTitleTextView = mTitle;
	}

	public TextView getLeftTextView() {
		return mLeftTextView;
	}

	public void setLeftTextView(TextView mLeftTextView) {
		this.mLeftTextView = mLeftTextView;
	}

	public TextView getRighTextView() {
		return mRightTextView;
	}

	public void setRighTextView(TextView mRighTextView) {
		this.mRightTextView = mRighTextView;
	}
	
	public View getLeftView() {
		return mLeftView;
	}

	public void setLeftView(View mLeftView) {
		this.mLeftView = mLeftView;
	}

	public View getRightView() {
		return mRightView;
	}

	public void setRightView(View mRightView) {
		this.mRightView = mRightView;
	}



	/**
	 * 
	 * @author lxy
	 *
	 */
	public interface TitleBarLeftAction
	{
		public void onLeftPress(View view);
	}
	/**
	 * 
	 * @author lxy
	 *
	 */
	public interface TitleBarRightAction
	{
		public void onRightPress(View view);
	}
	
}
